package me.xiaosiqi.syt.comm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration  {
    @Bean
    public Docket webApiConfig() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(webApiInfo())
                //分组名称
                .groupName("webApi")
                .select()
                .paths(PathSelectors.any().and(PathSelectors.regex("/api/.*")))
                .build();
        return docket;
    }


    @Bean
    public Docket adminApiConfig() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(AdminApiInfo())
                //分组名称
                .groupName("adminApi")
                .select()
                .paths(PathSelectors.any().and(PathSelectors.regex("/admin/.*")))
                .build();
        return docket;
    }

    private ApiInfo webApiInfo() {
        return new ApiInfoBuilder()
                .title("尚医堂-前台-API文档")
                .description("本文档描述前台网站系统微服务接口定义")
                .version("1.0")
                .contact(new Contact("xiaosiqi","http://xiaosiqi.me","xiao-si-qi@qq.com"))
                .build();
    }
    private ApiInfo AdminApiInfo() {
        return new ApiInfoBuilder()
                .title("尚医堂-后台管理系统-API文档")
                .description("本文档描述后台管理系统微服务接口定义")
                .version("1.0")
                .contact(new Contact("xiaosiqi","http://xiaosiqi.me","xiao-si-qi@qq.com"))
                .build();
    }
}